<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    function Parent(msg){
        this.msg = msg;
        this.show = function(){
            console.log(this.msg)
        }
    }
    Parent.prototype.init = function(){
        console.log("这是init", this.msg);
    }
    
    // const p = new Parent("hello");
    // console.log(p);
    // p.init();
    // p.show();


    const Child = extend(Parent);
    const c = new Child("world");
    console.log(c);
    c.show();
    c.init();

    function extend(Parent){
        function Child(msg){
            Parent.call(this, msg);
        }
        Child.prototype = {
            ...Parent.prototype
        }
        return Child;
    }
    

    
</script>
</html>